$(function() {
	var searchCount = $(".box-head").length, i=0;
	$(".box-head").each(function() {
		if(i > 0) {
			$(this).show();
			if(i == searchCount - 1) {
				$("#submitSearch").appendTo($(this).find(".left"));
				$("#addSearch").appendTo($(this).find(".left"));
				$("#addSearch").on("click", function() {
					var newSearch = $($(".box-head").get(0)).clone();
					newSearch.show();
					$("form").append(newSearch);
				})
			}
		}
		i ++;
	});
});

function changeOppositeProperty(obj) {
	if($(obj).prop("checked")) {
		$(obj).prev().val("1");
	} else {
		$(obj).prev().val("0");
	}
}

function deleteAnalysis(id,tabid){

	var param = {"id":id};
    API.deleteAnalysis(param, function(res) {
        if (res.code == '0') {
            window.location.reload();
        } else {
            alert(res.desc);
        }
    });
}

function cannotTag(id){
	var param = {"id":id};
	API.cannottagAnalysis(param, function(res) {
        if (res.code == '0') {
            window.location.reload();
        } else {
            alert(res.desc);
        }
    });
}

function canTag(id,tabid){
	var param = {"id":id};
	API.cantagAnalysis(param, function(res) {
        if (res.code == '0') {
            window.location.reload();
        } else {
            alert(res.desc);
        }
    });
}

function recoveryAnalysis(id,tabid){
    var param = {"id":id};
    API.recoverAnalysis(param, function(res) {
        if (res.code == '0') {
            window.location.reload();
        } else {
            alert(res.desc);
        }
    });
}